﻿
Imports std

Namespace internalFunctions
    Public Module _std
        Public Function _int(ByVal ps() As Object, ByRef o As Int64) As Boolean
            Dim b As bare_variable = Nothing
            Return paramarray_get(0, b, ps) AndAlso _variableconvertor._int(b, o)
        End Function

        Public Function match(ByVal i As Object, _
                              ByVal et1 As typeDefination, _
                              ByVal ParamArray ps() As Object) As Boolean
            assert(Not ps Is Nothing AndAlso ps.Length() = 1)
            Return Not i Is Nothing AndAlso _
                   matchtype(et1, ps(0))
        End Function
    End Module

    'parameters, obj, the input object, should be std.*
    'return, int, input.size
    Public Class stdsizeof
        Inherits internalFunction

        Public Class parameters
            Public Const obj As String = "obj"
        End Class

        Private Shared m As iParametersMapping = Nothing

        Public Sub New()
            MyBase.New("std.sizeof", m)
        End Sub

        Private Class callbackV
            Inherits vd_t(Of Int64)

            Protected Overrides Function cb(Of T) _
                                           (ByRef i As vector(Of T), _
                                            ByRef rtn As Int64, _
                                            ByVal ParamArray para() As Object) As Boolean
                If Not i Is Nothing Then
                    rtn = i.size()
                    Return True
                Else
                    raiseError("expect input object is not nothing.", errorHandle.errorType.exclamation)
                    Return False
                End If
            End Function
        End Class

        Private Class callbackS
            Inherits sd_t(Of Int64)

            Protected Overrides Function cb(Of T As IComparable(Of T)) _
                                           (ByRef i As [set](Of T), ByRef rtn As Int64, _
                                            ByVal ParamArray para() As Object) As Boolean
                If Not i Is Nothing Then
                    rtn = i.size()
                    Return True
                Else
                    raiseError("expect input object is not nothing.", errorHandle.errorType.exclamation)
                    Return False
                End If
            End Function
        End Class

        Private Class callbackL
            Inherits ld_t(Of Int64)

            Protected Overrides Function cb(Of T) _
                                           (ByRef i As list(Of T), ByRef rtn As Int64, _
                                            ByVal ParamArray para() As Object) As Boolean
                If Not i Is Nothing Then
                    rtn = i.size()
                    Return True
                Else
                    raiseError("expect input object is not nothing.", errorHandle.errorType.exclamation)
                    Return False
                End If
            End Function
        End Class

        Private Class callbackM
            Inherits md_t(Of Int64)

            Protected Overrides Function cb(Of T As IComparable(Of T), T2) _
                                           (ByRef i As map(Of T, T2), _
                                            ByRef rtn As Int64, _
                                            ByVal ParamArray para() As Object) As Boolean
                If Not i Is Nothing Then
                    rtn = i.size()
                    Return True
                Else
                    raiseError("expect input object is not nothing.", errorHandle.errorType.exclamation)
                    Return False
                End If
            End Function
        End Class

        Private Shared cbm As callbackM = Nothing
        Private Shared cbv As callbackV = Nothing
        Private Shared cbs As callbackS = Nothing
        Private Shared cbl As callbackL = Nothing

        Shared Sub New()
            cbm = New callbackM()
            cbv = New callbackV()
            cbs = New callbackS()
            cbl = New callbackL()
            initialMapping(m, parameters.obj)
        End Sub

        Protected Overrides Function invoke(ByVal ctx As context, ByRef output As bare_variable) As Boolean
            Dim input As bare_variable = Nothing
            input = ctx.findVariable(parameters.obj)
            If input Is Nothing Then
                raiseError("expect parameter " + parameters.obj, errorHandle.errorType.user)
                Return False
            Else
                Dim rtn As Int64
                If input.invoke(rtn, cbm, cbv, cbs, cbl) Then
                    output = New bare_variable(typeDefination.int, rtn)
                    Return True
                Else
                    Return False
                End If
            End If
        End Function
    End Class

    'parameters, obj, input std.* object
    '            value, another object need to insert to input
    '            value2, for map only, the third object, insert by input(value)=value2
    'return, bool, whether the insert operation is success or not
    Public Class stdinsert
        Inherits internalFunction

        Public Class parameters
            Public Const obj As String = "obj"
            Public Const value As String = "value"
            Public Const value2 As String = "value2"
        End Class

        Private Shared m As iParametersMapping = Nothing

        Public Sub New()
            MyBase.New("std.insert", m)
        End Sub

        Private Shared Function match(Of T)(ByVal i As T, ByVal ET As typeDefination, _
                                            ByVal ParamArray ps() As Object) As Boolean
            assert(Not ps Is Nothing AndAlso ps.Length() = 1)
            Return Not i Is Nothing AndAlso matchtype(ET, ps(0))
        End Function

        Private Class callbackV
            Inherits vd_t(Of Boolean)

            Public Overrides Function cb(Of T) _
                                        (ByRef i As vector(Of T), _
                                         ByRef rtn As Boolean, _
                                         ByVal ET As typeDefination, _
                                         ByVal ParamArray ps() As Object) As Boolean
                If match(i, ET, ps) Then
                    rtn = i.push_back(convertor.cast(Of T)(convertor.cast(Of bare_variable)(ps(0)).value()))
                    Return True
                Else
                    raiseError("expect input object is not nothing, and also match type.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Class callbackS
            Inherits sd_t(Of Boolean)

            Public Overrides Function cb(Of T As IComparable(Of T)) _
                                        (ByRef i As [set](Of T), _
                                         ByRef rtn As Boolean, _
                                         ByVal ET As typeDefination, _
                                         ByVal ParamArray ps() As Object) As Boolean
                If match(i, ET, ps) Then
                    rtn = (i.insert(convertor.cast(Of T)(convertor.cast(Of bare_variable)(ps(0)).value())) <> i.end())
                    Return True
                Else
                    raiseError("expect input object is not nothing, and also match type.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Class callbackL
            Inherits ld_t(Of Boolean)

            Public Overrides Function cb(Of T) _
                                        (ByRef i As list(Of T), _
                                         ByRef rtn As Boolean, _
                                         ByVal et As typeDefination, _
                                         ByVal ParamArray ps() As Object) As Boolean
                If match(i, et, ps) Then
                    rtn = i.push_back(convertor.cast(Of T)(convertor.cast(Of bare_variable)(ps(0)).value()))
                    Return True
                Else
                    raiseError("expect input object is not nothing, and also match type.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Shared Function match(Of T)(ByVal i As T, _
                                            ByVal ET1 As typeDefination, ByVal ET2 As typeDefination, _
                                            ByVal ParamArray ps() As Object) As Boolean
            assert(Not ps Is Nothing AndAlso ps.Length = 1)
            If Not i Is Nothing AndAlso _
               istype(Of pair(Of pointer(Of bare_variable), pointer(Of bare_variable)), Object)(ps(0)) Then
                Dim j As pair(Of pointer(Of bare_variable), pointer(Of bare_variable)) = Nothing
                j = convertor.cast(Of pair(Of pointer(Of bare_variable), pointer(Of bare_variable)))(ps(0))
                Return matchtype(ET1, +(j.first)) AndAlso matchtype(ET2, +(j.second))
            Else
                Return False
            End If
        End Function

        Private Class callbackM
            Inherits md_t(Of Boolean)

            Public Overrides Function cb(Of T As IComparable(Of T), T2) _
                                        (ByRef i As map(Of T, T2), _
                                         ByRef rtn As Boolean, _
                                         ByVal ET1 As typeDefination, ByVal ET2 As typeDefination, _
                                         ByVal ParamArray ps() As Object) As Boolean
                If match(i, ET1, ET2, ps) Then
                    Dim ii2 As pair(Of pointer(Of bare_variable), pointer(Of bare_variable)) = Nothing
                    ii2 = convertor.cast(Of pair(Of pointer(Of bare_variable), pointer(Of bare_variable)))(ps(0))
                    i(convertor.cast(Of T)((+(ii2.first)).value())) = convertor.cast(Of T2)((+(ii2.second)).value())
                    rtn = True
                    Return True
                Else
                    raiseError("expect input object is not nothing, and also match type.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Shared cbm As callbackM = Nothing
        Private Shared cbv As callbackV = Nothing
        Private Shared cbs As callbackS = Nothing
        Private Shared cbl As callbackL = Nothing

        Shared Sub New()
            cbm = New callbackM()
            cbv = New callbackV()
            cbs = New callbackS()
            cbl = New callbackL()
            initialMapping(m, parameters.obj, parameters.value, parameters.value2)
        End Sub

        Protected Overrides Function invoke(ByVal ctx As context, ByRef output As bare_variable) As Boolean
            Dim input As bare_variable = Nothing
            input = ctx.findVariable(parameters.obj)
            If input Is Nothing Then
                raiseError("expect parameter " + parameters.obj, errorHandle.errorType.user)
                Return False
            Else
                Dim input2 As bare_variable = Nothing
                input2 = ctx.findVariable(parameters.value)
                If input2 Is Nothing Then
                    raiseError("expect parameter " + parameters.value, errorHandle.errorType.user)
                    Return False
                Else
                    If input.variable().isType(typeDefination.map) Then
                        Dim input3 As bare_variable = Nothing
                        input3 = ctx.findVariable(parameters.value2)
                        If input3 Is Nothing Then
                            raiseError("expect parameter " + parameters.value2, errorHandle.errorType.user)
                            Return False
                        Else
                            Dim rtn As Boolean = Nothing
                            If input.invoke(rtn, cbm, cbv, cbs, cbl, _
                                            make_pair(New pointer(Of bare_variable)(input2), _
                                                      New pointer(Of bare_variable)(input3))) Then
                                output = New bare_variable(typeDefination.bool, rtn)
                                Return True
                            Else
                                Return False
                            End If
                        End If
                    ElseIf input.variable().isStdType() Then
                        Dim rtn As Boolean
                        If input.invoke(rtn, cbm, cbv, cbs, cbl, input2) Then
                            output = New bare_variable(typeDefination.bool, rtn)
                            Return True
                        Else
                            Return False
                        End If
                    Else
                        raiseError("expect parameter " + parameters.obj + " is an std.* object.", _
                                   errorHandle.errorType.user)
                        Return False
                    End If
                End If
                Return True
            End If
        End Function
    End Class

    'parameters, obj, input std.* object
    '            value, another object<index/name for string> need to take from input
    'return, same as elementType or elementType2<map>, the object take from input
    Public Class stdtake
        Inherits internalFunction

        Public Class parameters
            Public Const obj As String = "obj"
            Public Const value As String = "value"
        End Class

        Private Shared m As iParametersMapping = Nothing

        Public Sub New()
            MyBase.New("std.take", m)
        End Sub

        Private Class callbackV
            Inherits vd_t(Of Object)

            Protected Overrides Function cb(Of T) _
                                           (ByRef i As vector(Of T), _
                                            ByRef rtn As Object, _
                                            ByVal ParamArray ps() As Object) As Boolean
                Dim i2 As Int64 = Nothing
                If _int(ps, i2) Then
                    Try
                        rtn = i(i2)
                        Return True
                    Catch ex As Exception
                        raiseError("cannot get element from vector, ex " + _
                                   ex.Message + ", callstack " + ex.StackTrace, errorHandle.errorType.user)
                        Return False
                    End Try
                Else
                    raiseError("expect input object is not nothing, and also i2 is int.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Class callbackS
            Inherits sd_t(Of Object)

            Protected Overrides Function cb(Of T As IComparable(Of T)) _
                                           (ByRef i As [set](Of T), ByRef rtn As Object, _
                                            ByVal ParamArray ps() As Object) As Boolean
                Dim i2 As Int64 = Nothing
                If _int(ps, i2) Then
                    Try
                        rtn = +(i(i2))
                        Return True
                    Catch ex As Exception
                        raiseError("cannot get element from set, ex " + _
                                    ex.Message + ", callstack " + ex.StackTrace, errorHandle.errorType.user)
                        Return False
                    End Try
                Else
                    raiseError("expect input object is not nothing, and also i2 is int.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Class callbackL
            Inherits ld_t(Of Object)

            Protected Overrides Function cb(Of T) _
                                           (ByRef i As list(Of T), ByRef rtn As Object, _
                                            ByVal ParamArray ps() As Object) As Boolean
                Dim i2 As Int64 = Nothing
                If _int(ps, i2) Then
                    Try
                        rtn = i(i2)
                        Return True
                    Catch ex As Exception
                        raiseError("cannot get element from list, ex " + _
                                   ex.Message + ", callstack " + ex.StackTrace, errorHandle.errorType.user)
                        Return False
                    End Try
                Else
                    raiseError("expect input object is not nothing, and also i2 is int.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Class callbackM
            Inherits md_t(Of Object)

            Public Overrides Function cb(Of T As IComparable(Of T), T2) _
                                        (ByRef i As map(Of T, T2), ByRef rtn As Object, _
                                         ByVal ET1 As typeDefination, ByVal ET2 As typeDefination, _
                                         ByVal ParamArray ps() As Object) As Boolean
                If match(i, et1, ps) Then
                    Try
                        rtn = i(convertor.cast(Of T)(convertor.cast(Of bare_variable)(ps(0)).value()))
                        Return True
                    Catch ex As Exception
                        raiseError("cannot get element from map, ex " + _
                                   ex.Message + ", callstack " + ex.StackTrace, errorHandle.errorType.user)
                        Return False
                    End Try
                Else
                    raiseError("expect input object is not nothing, and also match type.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Shared cbm As callbackM = Nothing
        Private Shared cbv As callbackV = Nothing
        Private Shared cbs As callbackS = Nothing
        Private Shared cbl As callbackL = Nothing

        Shared Sub New()
            cbm = New callbackM()
            cbv = New callbackV()
            cbs = New callbackS()
            cbl = New callbackL()
            initialMapping(m, parameters.obj, parameters.value)
        End Sub

        Protected Overrides Function invoke(ByVal ctx As context, ByRef output As bare_variable) As Boolean
            Dim input As bare_variable = Nothing
            input = ctx.findVariable(parameters.obj)
            If input Is Nothing Then
                raiseError("expect parameter " + parameters.obj, errorHandle.errorType.user)
                Return False
            Else
                Dim input2 As bare_variable = Nothing
                input2 = ctx.findVariable(parameters.value)
                If input2 Is Nothing Then
                    raiseError("expect parameter " + parameters.value, errorHandle.errorType.user)
                    Return False
                Else
                    Dim outputT As typeDefination = typeDefination.unknown
                    If input.variable().isType(typeDefination.map) Then
                        outputT = input.variable().elementType2()
                    ElseIf input.variable().isStdType() Then
                        outputT = input.variable().elementType1()
                    Else
                        raiseError("expect parameter " + parameters.value + " is std.* object.", _
                                   errorHandle.errorType.user)
                        Return False
                    End If
                    Dim obj As Object = Nothing
                    If input.invoke(obj, cbm, cbv, cbs, cbl, input2) Then
                        output = New bare_variable(outputT, obj)
                        Return True
                    Else
                        Return False
                    End If
                End If
                Return True
            End If
        End Function
    End Class

    'parameters, obj, input std.* object
    '            value, another object need to find from input
    'return, bool, whether found or not
    Public Class stdfind
        Inherits internalFunction

        Public Class parameters
            Public Const obj As String = "obj"
            Public Const value As String = "value"
        End Class

        Private Shared m As iParametersMapping = Nothing

        Public Sub New()
            MyBase.New("std.find", m)
        End Sub

        Private Shared Function match(ByVal i As Object, ByVal et As typeDefination, _
                                      ByVal ParamArray ps() As Object) As Boolean
            assert(Not ps Is Nothing AndAlso ps.Length() = 1)
            Return Not i Is Nothing AndAlso _
                   matchtype(et, ps(0))
        End Function

        Private Class callbackV
            Inherits vd_t(Of Boolean)

            Public Overrides Function cb(Of T) _
                                        (ByRef i As vector(Of T), ByRef rtn As Boolean, _
                                         ByVal ET As typeDefination, _
                                         ByVal ParamArray ps() As Object) As Boolean
                If match(i, ET, ps) Then
                    rtn = (i.find(convertor.cast(Of T)(convertor.cast(Of bare_variable)(ps(0)).value())) <> npos)
                    Return True
                Else
                    raiseError("expect input object is not nothing, and also i2 is int.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Class callbackS
            Inherits sd_t(Of Boolean)

            Public Overrides Function cb(Of T As IComparable(Of T)) _
                                        (ByRef i As [set](Of T), ByRef rtn As Boolean, _
                                         ByVal ET As typeDefination, _
                                         ByVal ParamArray ps() As Object) As Boolean
                If match(i, ET, ps) Then
                    rtn = (i.find(convertor.cast(Of T)(convertor.cast(Of bare_variable)(ps(0)).value())) <> i.end())
                    Return True
                Else
                    raiseError("expect input object is not nothing, and also i2 is int.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Class callbackL
            Inherits ld_t(Of Boolean)

            Public Overrides Function cb(Of T) _
                                        (ByRef i As list(Of T), ByRef rtn As Boolean, _
                                         ByVal ET As typeDefination, _
                                         ByVal ParamArray ps() As Object) As Boolean
                If match(i, ET, ps) Then
                    rtn = (i.find(convertor.cast(Of T)(convertor.cast(Of bare_variable)(ps(0)).value())) <> i.end())
                    Return True
                Else
                    raiseError("expect input object is not nothing, and also i2 is int.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Class callbackM
            Inherits md_t(Of Boolean)

            Public Overrides Function cb(Of T As IComparable(Of T), T2) _
                                        (ByRef i As map(Of T, T2), _
                                         ByRef rtn As Boolean, _
                                         ByVal et1 As typeDefination, ByVal et2 As typeDefination, _
                                         ByVal ParamArray ps() As Object) As Boolean
                If match(i, et1, ps) Then
                    rtn = (i.find(convertor.cast(Of T)(convertor.cast(Of bare_variable)(ps(0)).value())) <> i.end())
                    Return True
                Else
                    raiseError("expect input object is not nothing, and also match type.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Shared cbm As callbackM = Nothing
        Private Shared cbv As callbackV = Nothing
        Private Shared cbs As callbackS = Nothing
        Private Shared cbl As callbackL = Nothing

        Shared Sub New()
            cbm = New callbackM()
            cbv = New callbackV()
            cbs = New callbackS()
            cbl = New callbackL()
            initialMapping(m, parameters.obj, parameters.value)
        End Sub

        Protected Overrides Function invoke(ByVal ctx As context, ByRef output As bare_variable) As Boolean
            Dim input As bare_variable = Nothing
            input = ctx.findVariable(parameters.obj)
            If input Is Nothing Then
                raiseError("expect parameter " + parameters.obj, errorHandle.errorType.user)
                Return False
            Else
                Dim input2 As bare_variable = Nothing
                input2 = ctx.findVariable(parameters.value)
                If input2 Is Nothing Then
                    raiseError("expect parameter " + parameters.value, errorHandle.errorType.user)
                    Return False
                Else
                    Dim rtn As Boolean = Nothing
                    If input.invoke(rtn, cbm, cbv, cbs, cbl, input2) Then
                        output = New bare_variable(typeDefination.bool, rtn)
                        Return True
                    Else
                        Return False
                    End If
                End If
                Return True
            End If
        End Function
    End Class

    'parameters, obj, input std.* object
    '            value, another object need to remove from input
    'return, bool, whether found or not
    Public Class stderase
        Inherits internalFunction

        Public Class parameters
            Public Const obj As String = "obj"
            Public Const value As String = "value"
        End Class

        Public Sub New()
            MyBase.New("std.erase")
        End Sub

        Private Class callbackV
            Inherits vd_t(Of Boolean)

            Protected Overrides Function cb(Of T) _
                                           (ByRef i As vector(Of T), ByRef rtn As Boolean, _
                                            ByVal ParamArray ps() As Object) As Boolean
                Dim i2 As Int64 = Nothing
                If _int(ps, i2) Then
                    Try
                        rtn = i.erase(i2)
                        Return True
                    Catch ex As Exception
                        raiseError("cannot erase element from vector, ex " + _
                                   ex.Message + ", callstack " + ex.StackTrace, errorHandle.errorType.user)
                        Return False
                    End Try
                Else
                    raiseError("expect input object is not nothing, and also i2 is int.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Class callbackL
            Inherits ld_t(Of Boolean)

            Protected Overrides Function cb(Of T) _
                                           (ByRef i As list(Of T), ByRef rtn As Boolean, _
                                            ByVal ParamArray ps() As Object) As Boolean
                Dim i2 As Int64 = Nothing
                If _int(ps, i2) Then
                    Try
                        rtn = i.availableIndex(i2)
                        If rtn Then
                            i.erase(i2)
                        End If
                        Return True
                    Catch ex As Exception
                        raiseError("cannot erase element from list, ex " + _
                                   ex.Message + ", callstack " + ex.StackTrace, errorHandle.errorType.user)
                        Return False
                    End Try
                Else
                    raiseError("expect input object is not nothing, and also i2 is int.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Class callbackS
            Inherits sd_t(Of Boolean)

            Public Overrides Function cb(Of T As IComparable(Of T)) _
                                        (ByRef i As [set](Of T), ByRef rtn As Boolean, _
                                         ByVal ET As typeDefination, _
                                         ByVal ParamArray ps() As Object) As Boolean
                If match(i, ET, ps) Then
                    Try
                        rtn = i.erase(convertor.cast(Of T)((convertor.cast(Of bare_variable)(ps(0)).value())))
                        Return True
                    Catch ex As Exception
                        raiseError("cannot erase element from set, ex " + _
                                    ex.Message + ", callstack " + ex.StackTrace, errorHandle.errorType.user)
                        Return False
                    End Try
                Else
                    raiseError("expect input object is not nothing, and also i2 is int.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Class callbackM
            Inherits md_t(Of Boolean)

            Public Overrides Function cb(Of T As IComparable(Of T), T2) _
                                        (ByRef i As map(Of T, T2), ByRef rtn As Boolean, _
                                         ByVal ET1 As typeDefination, ByVal ET2 As typeDefination, _
                                         ByVal ParamArray ps() As Object) As Boolean
                If match(i, ET1, ps) Then
                    Try
                        rtn = i.erase(convertor.cast(Of T)(convertor.cast(Of bare_variable)(ps(0)).value()))
                        Return True
                    Catch ex As Exception
                        raiseError("cannot erase element from map, ex " + _
                                   ex.Message + ", callstack " + ex.StackTrace, errorHandle.errorType.user)
                        Return False
                    End Try
                Else
                    raiseError("expect input object is not nothing, and also match type.", _
                               errorHandle.errorType.user)
                    Return False
                End If
            End Function
        End Class

        Private Shared cbm As callbackM = Nothing
        Private Shared cbv As callbackV = Nothing
        Private Shared cbs As callbackS = Nothing
        Private Shared cbl As callbackL = Nothing

        Shared Sub New()
            cbm = New callbackM()
            cbv = New callbackV()
            cbs = New callbackS()
            cbl = New callbackL()
        End Sub

        Protected Overrides Function invoke(ByVal ctx As context, ByRef output As bare_variable) As Boolean
            Dim input As bare_variable = Nothing
            input = ctx.findVariable(parameters.obj)
            If input Is Nothing Then
                raiseError("expect parameter " + parameters.obj, errorHandle.errorType.user)
                Return False
            Else
                Dim input2 As bare_variable = Nothing
                input2 = ctx.findVariable(parameters.value)
                If input2 Is Nothing Then
                    raiseError("expect parameter " + parameters.value, errorHandle.errorType.user)
                    Return False
                Else
                    Dim obj As Boolean = Nothing
                    If input.invoke(Of Boolean)(obj, cbm, cbv, cbs, cbl, input2) Then
                        output = New bare_variable(typeDefination.bool, obj)
                        Return True
                    Else
                        Return False
                    End If
                End If
                Return True
            End If
        End Function
    End Class
End Namespace